// Camera1DataThread
#include "mainwindow.h"


void Camera1DataThread::run()
{
    // int qos = 10;
    rclcpp::QoS video_qos(2);
    video_qos.keep_last(2);
    video_qos.best_effort();
    video_qos.durability_volatile();
    camera_node_cpp = rclcpp::Node::make_shared("camera_1_node");
    camera1_sub_ = camera_node_cpp->create_subscription<sensor_msgs::msg::CompressedImage>(
        "camera_1",1, std::bind(&Camera1DataThread::camera1_back, this, std::placeholders::_1));
    rclcpp::spin(camera_node_cpp);
}
void Camera1DataThread::camera1_back(const sensor_msgs::msg::CompressedImage::SharedPtr img_msg_1)
{
    // 将ROS压缩图像消息转换为OpenCV图像
    cv_bridge::CvImagePtr cv_ptr = cv_bridge::toCvCopy(img_msg_1, sensor_msgs::image_encodings::BGR8);
    // qDebug() << "";
    // QThread::sleep(0.01);
    img1 = cv_ptr->image;
    emit image_1Emit(img1);

}
